package com.zl.smartmall.library.po;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class Component implements Serializable {
	private String price;
	private String name;
	private String use_num;
	private String distribute_id;
	private String repair_price_id;
	private String id;
	public String getPrice() {
		return price;
	}
	public void setPrice(String price) {
		this.price = price;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getUse_num() {
		return use_num;
	}
	public void setUse_num(String use_num) {
		this.use_num = use_num;
	}
	public String getDistribute_id() {
		return distribute_id;
	}
	public void setDistribute_id(String distribute_id) {
		this.distribute_id = distribute_id;
	}
	public String getRepair_price_id() {
		return repair_price_id;
	}
	public void setRepair_price_id(String repair_price_id) {
		this.repair_price_id = repair_price_id;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public static List<Component> parse(JSONArray jsonArray) throws JSONException{
		List<Component> components = new ArrayList<Component>();
		for (int i = 0; i < jsonArray.length(); i++) {
			Component component = new Component();
			JSONObject jsonObject = jsonArray.getJSONObject(i);
			component.setPrice(jsonObject.getString("price"));
			component.setUse_num(jsonObject.getString("use_num"));
			component.setName(jsonObject.getString("name"));
			component.setId(jsonObject.getString("id"));
			component.setDistribute_id(jsonObject.getString("distribute_id"));
			component.setRepair_price_id(jsonObject.getString("repair_price_id"));
			components.add(component);

		}
		return components;
	}

}
